/*
 * MonitorCommand4Flash.h
 *
 *  Created on: Aug 30, 2013
 *      Author: wyf
 */

#ifndef MONITORCOMMAND4FLASH_H_
#define MONITORCOMMAND4FLASH_H_

#include "command.h"
#include "ctType.h"
#include <sys/types.h>

#define MAX_IP_LENGTH		16
#define MAX_PASSWORD_SIZE	32      //md5.
#define MAX_NAME_SIZE	        48      //昵称长度.     <=12汉字
#define MAX_ROOM_NAME_SIZE      64      //房间名称长度.
#define MAX_ACCOUNT_SIZE	64	//用户帐号长度.
#define MAX_DATETIME_SIZE	32      //
#pragma pack(1)

#define ERR_DATABASE	2
#define ERR_NODATA	3

namespace Cmd
{
	namespace MonitorFlash
	{
		//  cmd declaration
		enum
		{
			CMDIN_REAL              = 0x03E8,
			CMDIN_RMREAL            = 0x03E9,
			CMDIN_RMMT              = 0x03EA,
			CMDIN_RSVR              = 0x03EB,
			CMDIN_CTRL              = 0x03EC,
			CMDIN_MACH              = 0x03ED,
                        CMDIN_GM                = 0x03EE,
		};
		enum
		{ //CMDIN
			SCMDIN_REAL_TOTAL_REQ                   = 0x0001,
			SCMDIN_REAL_TOTAL_RES                   = 0x0002,
			SCMDIN_REAL_PEAK_REQ                    = 0x0003,
			SCMDIN_REAL_PEAK_RES                    = 0x0004,
			SCMDIN_REAL_HISTORY_REQ                 = 0x0005,
			SCMDIN_REAL_HISTORY_RES                 = 0x0006,
			SCMDIN_REAL_ROOMLOAD_REQ                = 0x0007,
			SCMDIN_REAL_ROOMLOAD_RES                = 0x0008,
		};
		enum
		{
			SCMDIN_ROOM_ROOMLIST_REQ                = 0x0001,
			SCMDIN_ROOM_ROOMLIST_RES                = 0x0002,
			SCMDIN_ROOM_HISDATA_BYTYPE_REQ          = 0x0003,
			SCMDIN_ROOM_HISDATA_BYTYPE_RES          = 0x0004,
			SCMDIN_ROOM_CURDATA_BYTYPE_REQ          = 0x0005,
			SCMDIN_ROOM_CURDATA_BYTYPE_RES          = 0x0006,
		};
		enum //1002
		{
			SCMDIN_RMMT_SEARCH_ROOM_REQ             = 0x0001,
			SCMDIN_RMMT_SEARCH_ROOM_RES             = 0x0002,
			SCMDIN_RMMT_MACHINE_REQ                 = 0x0003,
			SCMDIN_RMMT_MACHINE_RES                 = 0x0004,
			SCMDIN_RMMT_PERFORMANCE_REQ             = 0x0005,
			SCMDIN_RMMT_PERFORMANCE_RES             = 0x0006,
			SCMDIN_RMMT_ROOMLOAD_REQ                = 0x0007,
			SCMDIN_RMMT_ROOMLOAD_RES                = 0x0008,
			SCMDIN_RMMT_RELATIVEMACHINE_REQ         = 0x0009,
			SCMDIN_RMMT_RELATIVEMACHINE_RES         = 0x000A,
			SCMDIN_RMMT_SERVERLIST_REQ              = 0x000B,
			SCMDIN_RMMT_SERVERLIST_RES              = 0x000C,
			SCMDIN_RMMT_ROOM_DEPLOY_REQ             = 0x000D,
			SCMDIN_RMMT_ROOM_DEPLOY_RES             = 0x000E,
		};
		enum
		{
			SCMDIN_RSVR_HISLOAD_REQ                 = 0x0001,
			SCMDIN_RSVR_HISLOAD_RES                 = 0x0002,
			SCMDIN_RSVR_REALLOAD_REQ                = 0x0003,
			SCMDIN_RSVR_REALLOAD_RES                = 0x0004,
			SCMDIN_RSVR_GATEWAY_REAL_REQ            = 0x0005,
			SCMDIN_RSVR_GATEWAY_REAL_RES            = 0x0006,
		};
                enum
		{
			SCMDIN_CTRL_KILL                        = 0x0001,
		};
		enum
		{
			SCMDIN_MACH_PROC_REQ                    = 0x0001,
			SCMDIN_MACH_PROC_RES                    = 0x0002,
			SCMDIN_MACH_TOTAL_REQ                   = 0x0003,
			SCMDIN_MACH_TOTAL_RES                   = 0x0004,
			SCMDIN_MACH_PROC_STAT_REQ               = 0x0005,
			SCMDIN_MACH_PROC_STAT_RES               = 0x0006,
			SCMDIN_MACH_REAL_TOTAL_REQ              = 0x0007,
			SCMDIN_MACH_REAL_TOTAL_RES              = 0x0008,
			SCMDIN_MACH_SERVERS_REQ                 = 0x0009,
			SCMDIN_MACH_SERVERS_RES                 = 0x000A,
		};
                enum
                {
                        SCMDIN_GM_USER_ID_BY_ACCOUNT_REQ        = 0x0001,       // 请求用户ID信息
                        SCMDIN_GM_USER_ID_BY_ACCOUNT_RES        = 0x0002,       // 返回用户ID信息
                        SCMDIN_GM_USER_ACCOUNT_BY_ID_REQ        = 0x0003,       // 请求用户帐号信息
                        SCMDIN_GM_USER_ACCOUNT_BY_ID_RES        = 0x0004,       // 返回用户帐号信息
                        SCMDIN_GM_USER_ONLINE_INFO_REQ          = 0x0005,       // 请求用户在线信息
                        SCMDIN_GM_USER_ONLINE_INFO_RES          = 0x0006,       // 返回用户在线信息
                        SCMIND_GM_USER_ROOM_INFO_REQ            = 0x0007,       // 请求用户在线房间信息
                        SCMIND_GM_USER_ROOM_INFO_RES            = 0x0008,       // 返回用户在线房间信息
                        SCMDIN_GM_ROOMMEDIA_INFO_REQ            = 0x0009,       // 请求RoomMedia信息
                        SCMDIN_GM_ROOMMEDIA_INFO_RES            = 0x000A,       // 返回RoomMedia信息
                        SCMDIN_GM_DISPATCH_USER_TO_MEDIA_REQ    = 0x000B,       // 请求调度用户到RoomMedia
                        SCMDIN_GM_DISPATCH_USER_TO_MEDIA_RES    = 0x000C,       // 返回调度用户到RoomMedia
                        SCMDIN_GM_SPECIFIC_SERVER_LIST_REQ      = 0x000D,       // 请求特定房间指定服务器列表
                        SCMDIN_GM_SPECIFIC_SERVER_LIST_RES      = 0x000E,       // 返回特定房间指定服务器列表
                        SCMDIN_GM_ADD_SPECIFIC_SERVER_REQ       = 0x000F,       // 请求增加房间到指定服务器
                        SCMDIN_GM_ADD_SPECIFIC_SERVER_RES       = 0x0010,       // 返回增加房间到指定服务器
                        SCMDIN_GM_DEL_SPECIFIC_SERVER_REQ       = 0x0011,       // 请求删除房间到指定服务器
                        SCMDIN_GM_DEL_SPECIFIC_SERVER_RES       = 0x0012,       // 返回删除房间到指定服务器
                        SCMDIN_GM_DB_SERVERLIST_REQ             = 0x0013,       // 请求DB中的ServerList数据
                        SCMDIN_GM_DB_SERVERLIST_RES             = 0x0014,       // 返回DB中的ServerList数据
                        SCMDIN_GM_MEM_SERVERLIST_REQ            = 0x0015,       // 请求内存中的ServerList数据
                        SCMDIN_GM_MEM_SERVERLIST_RES            = 0x0016,       // 返回内存中的ServerList数据
                        SCMDIN_GM_RELOAD_SERVERLIST_NOTIFY      = 0x0017,       // 通知刷新内存中的ServerList数据
                        SCMDIN_GM_ADD_SERVER_REQ                = 0x0018,       // 请求添加服务器
                        SCMDIN_GM_ADD_SERVER_RES                = 0x0019,       // 返回添加服务器结果
                        SCMDIN_GM_DEL_SERVER_REQ                = 0x001A,       // 请求删除服务器
                        SCMDIN_GM_DEL_SERVER_RES                = 0x001B,       // 返回删除服务器结果
                };

		struct stMonitorBase: t_NullCmd
		{
                        stMonitorBase( WORD cmd, WORD subcmd )
                                : t_NullCmd( cmd, subcmd )
                        {
                                cid = 0;
                        }

                        DWORD cid;
		};
		//*************************************************************************************************
		//查询所有服务列表
		struct st_getProcessReq: stMonitorBase
		{
                        st_getProcessReq()
                                : stMonitorBase( CMDIN_MACH, SCMDIN_MACH_PROC_REQ )		//1005,1
                        {
                        }
		};
		//返回服务列表
		struct st_getProcessRes: stMonitorBase
		{
                        st_getProcessRes()
                                : stMonitorBase( CMDIN_MACH, SCMDIN_MACH_PROC_RES )		//1005,2
                        {
                                ret_code_ = 0;
                                size_ = 0;
                        }
                        WORD ret_code_;
                        WORD size_;

                        struct stRUL
                        {
                                DWORD procid;		//进程id
                                DWORD serverid;		//服务id
                                char servername[MAX_ROOM_NAME_SIZE + 1];		//服务名称
                                char serverip[MAX_IP_LENGTH + 1];		//服务器IP

                        } list_[0];
                        DWORD getSize()
                        {
                                return sizeof( *this ) + size_ * sizeof( list_[0] );
                        }

                };

                //查询物理机趋势
                struct st_getTotalReq: stMonitorBase
                {
                        st_getTotalReq()
                                : stMonitorBase( CMDIN_MACH, SCMDIN_MACH_TOTAL_REQ )		//1005,3
                        {
                                unit = 0;
                                value = 0;
                        }

                        char serverip[MAX_IP_LENGTH + 1];		//物理机IP
                        char fromtime[MAX_DATETIME_SIZE + 1];		//取数据起始时间
                        char totime[MAX_DATETIME_SIZE + 1]; //结束时间
                        BYTE unit; //按照此时间取一次数据//0分钟    1小时
                        WORD value; //如果unit=0，values表示分钟数。

                };
                //返回列表
                struct st_getTotalRes: stMonitorBase
                {
                        st_getTotalRes()
                                : stMonitorBase( CMDIN_MACH, SCMDIN_MACH_TOTAL_RES ) //1005,4
                        {
                                ret_code_ = 0;
                                size_ = 0;
                        }

                        WORD ret_code_;
                        WORD size_;

                        char serverip[MAX_IP_LENGTH + 1]; //
                        struct stRUL
                        {
                                DWORD cpu_user; //
                                DWORD cpu_sys; //
                                DWORD mem_vm; //
                                DWORD mem_phy; //
                                DWORD net_send; //
                                DWORD net_recv; //
                                BYTE updatetime[MAX_DATETIME_SIZE + 1]; //数据对应的时间

                        } list_[0];
                        DWORD getSize()
                        {
                                return sizeof( *this ) + size_ * sizeof( list_[0] );
                        }

                };

                //查询cpu和mem趋势
                struct st_getProcStatReq: stMonitorBase
                {
                        st_getProcStatReq()
                                : stMonitorBase( CMDIN_MACH, SCMDIN_MACH_PROC_STAT_REQ ) //1005,5
                        {
                                serverid = 0;
                                unit = 0;
                                value = 0;
                        }

                        DWORD serverid;
                        char fromtime[MAX_DATETIME_SIZE + 1]; //取数据起始时间
                        char totime[MAX_DATETIME_SIZE + 1]; //结束时间
                        BYTE unit; //按照此时间取一次数据//0分钟    1小时
                        WORD value; //如果unit=0，values表示分钟数。

                };
                //返回列表
                struct st_getProcStatRes: stMonitorBase
                {
                        st_getProcStatRes()
                                : stMonitorBase( CMDIN_MACH, SCMDIN_MACH_PROC_STAT_RES ) //1005,6
                        {
                                ret_code_ = 0;
                                size_ = 0;
                                serverid = 0;
                        }

                        WORD ret_code_;
                        WORD size_;
                        DWORD serverid;
                        struct stRUL
                        {
                                DWORD cpu_user; //
                                DWORD cpu_sys; //
                                DWORD mem_vm; //
                                DWORD mem_phy; //
                                BYTE updatetime[MAX_DATETIME_SIZE + 1]; //数据对应的时间

                        } list_[0];
                        DWORD getSize()
                        {
                                return sizeof( *this ) + size_ * sizeof( list_[0] );
                        }

                };

                //物理机实时性能
                struct st_getMachineRealReq: stMonitorBase
                {
                        st_getMachineRealReq()
                                : stMonitorBase( CMDIN_MACH, SCMDIN_MACH_REAL_TOTAL_REQ ) //1005,7
                        {

                        }

                        char serverip[MAX_IP_LENGTH + 1]; //物理机IP   =“0”查询所有， =“IP”，查询指定ip的机器

                };
                //返回列表
                struct st_getMachineRealRes: stMonitorBase
                {
                        st_getMachineRealRes()
                                : stMonitorBase( CMDIN_MACH, SCMDIN_MACH_REAL_TOTAL_RES ) //1005,8
                        {
                                size_ = 0;
                                ret_code_ = 0;
                        }
                        WORD ret_code_;
                        char serverip[MAX_IP_LENGTH + 1]; //
                        WORD size_;
                        struct stRUL
                        {
                                DWORD cpu; //
                                DWORD mem; //
                                DWORD net; //
                                DWORD servers; //
                                char ip[MAX_IP_LENGTH + 1]; //数据对应的时间
                                char name[MAX_ROOM_NAME_SIZE + 1]; //机房名称

                        } list_[0];
                        DWORD getSize()
                        {
                                return sizeof( *this ) + size_ * sizeof( list_[0] );
                        }

                };
                //查询物理机上的搭载的服务
                struct st_getMachineServerReq: stMonitorBase
                {
                        st_getMachineServerReq()
                                : stMonitorBase( CMDIN_MACH, SCMDIN_MACH_SERVERS_REQ ) //1005,9
                        {

                        }

                        char serverip[MAX_IP_LENGTH + 1]; //

                };
                //返回列表
                struct st_getMachineServerRes: stMonitorBase
                {
                        st_getMachineServerRes()
                                : stMonitorBase( CMDIN_MACH, SCMDIN_MACH_SERVERS_RES ) //1005,8
                        {
                                size_ = 0;
                                ret_code_ = 0;
                        }

                        WORD ret_code_;
                        char serverip[MAX_IP_LENGTH + 1]; //
                        WORD size_;
                        struct stRUL
                        {
                                DWORD type;
                                DWORD id; //
                                char ip[MAX_IP_LENGTH + 1]; //
                                DWORD load;

                        } list_[0];
                        DWORD getSize()
                        {
                                return sizeof( *this ) + size_ * sizeof( list_[0] );
                        }

                };

                //**************************************************************************************************
                //查询房间 by name
                struct st_searchRoomReq: stMonitorBase
                {
                        st_searchRoomReq()
                                : stMonitorBase( CMDIN_RMMT, SCMDIN_RMMT_SEARCH_ROOM_REQ )
                        {
                                searchType = 0;
                        }
                        WORD searchType;
                        char queryname[MAX_ROOM_NAME_SIZE + 1];		//房间名称，或者用户名

                };
                struct st_searchRoomRes: stMonitorBase
                {
                        st_searchRoomRes()
                                : stMonitorBase( CMDIN_RMMT, SCMDIN_RMMT_SEARCH_ROOM_RES )
                        {
                                ret_code_ = 1;
                                size_ = 0;
                        }
                        WORD ret_code_;
                        WORD size_;
                        struct stRUL
                        {
                                DWORD roomid;		//房间ID
                                DWORD total;		//显示人数
                                DWORD realtotal;		//真实人数
                                DWORD dummys;		//马甲人数
                                DWORD medias;		//语音数
                                DWORD serverid;
                                char roomname[MAX_ROOM_NAME_SIZE + 1];

                        } list_[0];
                        DWORD getSize()
                        {
                                return sizeof( *this ) + size_ * sizeof( list_[0] );
                        }

                };

                //查询物理机数据
                struct st_searchMachineReq: stMonitorBase
                {
                        st_searchMachineReq()
                                : stMonitorBase( CMDIN_RMMT, SCMDIN_RMMT_MACHINE_REQ )
                        {
                                serverid = 0;
                        }
                        DWORD serverid;		// 非0，使用serverid查询， =0，使用下面serverip查询
                        BYTE serverip[MAX_IP_LENGTH + 1];		//服务器内网IP（此处暂时不用）

                };
                //返回
                struct st_searchMachineRes: stMonitorBase
                {
                        st_searchMachineRes()
                                : stMonitorBase( CMDIN_RMMT, SCMDIN_RMMT_MACHINE_RES )
                        {
                                port = 0;
                                dxport = 0;
                                wtport = 0;
                                ret_code_ = 1;
                        }
                        WORD ret_code_;

                        char stationName[MAX_ROOM_NAME_SIZE + 1];		//机房名称
                        char interIP[MAX_IP_LENGTH + 1];		//内网IP
                        char outerIP[MAX_IP_LENGTH + 1];		//外网IP
                        char dxIP[MAX_IP_LENGTH + 1];		//电信IP
                        char wtIP[MAX_IP_LENGTH + 1];		//网通IP
                        DWORD port;		//端口
                        DWORD dxport;		//电信端口
                        DWORD wtport;		//网通端口

                };

                //查询服务器性能数据
                struct st_sysPerformanceReq: stMonitorBase
                {
                        st_sysPerformanceReq()
                                : stMonitorBase( CMDIN_RMMT, SCMDIN_RMMT_PERFORMANCE_REQ )
                        {
                                serverid = 1;
                        }
                        DWORD serverid;		// 非0，使用serverid查询， =0，使用下面serverip查询
                        char serverip[MAX_IP_LENGTH + 1];		//服务器内网IP

                };
                //返回
                struct st_sysPerformanceRes: stMonitorBase
                {
                        st_sysPerformanceRes()
                                : stMonitorBase( CMDIN_RMMT, SCMDIN_RMMT_PERFORMANCE_RES )
                        {
                                ret_code_ = 1;
                                cpu = 0;
                                net = 0;
                                mem = 0;
                                dxnet = 0;
                                wtnet = 0;
                        }
                        WORD ret_code_;

                        DWORD cpu;		//cpu占用
                        DWORD net;		//带宽占用
                        DWORD mem;		//内存占用情况
                        DWORD wtnet;		//网通带宽占用
                        DWORD dxnet;		//电信带宽占用
                };
                //查询房间实时数据接口3-按照服务器类型查询
                struct st_RoomloadByServerReq: stMonitorBase
                {

                        st_RoomloadByServerReq()
                                : stMonitorBase( CMDIN_RMMT, SCMDIN_RMMT_ROOMLOAD_REQ )
                        {
                                servertype = 0;
                                numbers = 1;
                                roomserverid = 0;
                        }

                        WORD servertype;		//6，Roomserver 3，Sessionserver  （此处使用6）
                        WORD numbers;		//需要查询的房间个数
                        DWORD roomserverid;		//
                };
                //返回
                struct st_RoomloadByServerRes: stMonitorBase
                {

                        st_RoomloadByServerRes()
                                : stMonitorBase( CMDIN_RMMT, SCMDIN_RMMT_ROOMLOAD_RES )
                        {
                                ret_code_ = 0;
                                roomserverid = 0;
                                maxload = 0;
                                other_realtotal = 0;
                                size_ = 0;
                        }
                        DWORD ret_code_;

                        DWORD roomserverid;		//
                        DWORD maxload;
                        DWORD other_realtotal;		//other真实人数

                        WORD size_;		//如下结构的个数
                        struct stRUL
                        {
                                DWORD roomid;		//ID
                                DWORD realtotal;		//真实人数
                                WORD roomtype;		//房间类型
                                char roomname[MAX_ROOM_NAME_SIZE + 1];		//名称

                        } list[0];
                        DWORD getSize()
                        {
                                return sizeof( *this ) + size_ * sizeof( list[0] );
                        }
                };

                //查询关联的服务器物理机数据
                struct st_RelativeMachineReq: stMonitorBase
                {
                        st_RelativeMachineReq()
                                : stMonitorBase( CMDIN_RMMT, SCMDIN_RMMT_RELATIVEMACHINE_REQ )
                        {
                                servertype = 0;
                                serverid = 0;
                        }

                        WORD servertype;		//6，Roomserver 3，Sessionserver  （此处使用6）
                        DWORD serverid;

                };
                //返回
                struct st_RelativeMachineRes: stMonitorBase
                {
                        st_RelativeMachineRes()
                                : stMonitorBase( CMDIN_RMMT, SCMDIN_RMMT_RELATIVEMACHINE_RES )
                        {
                                ret_code_ = 1;
                                servertype = 0;
                                serverid = 0;
                                size_ = 0;
                        }
                        WORD ret_code_;
                        DWORD serverid;
                        WORD servertype;

                        WORD size_;		//下面list元素的个数
                        struct stRUL
                        {
                                DWORD serverid;
                                WORD servertype;		//6，Roomserver 3，Sessionserver
                                char stationName[MAX_ROOM_NAME_SIZE + 1];		//机房名称
                                char interIP[MAX_IP_LENGTH + 1];		//内网IP
                                char outerIP[MAX_IP_LENGTH + 1];		//外网IP
                                char dxIP[MAX_IP_LENGTH + 1];		//电信IP
                                char wtIP[MAX_IP_LENGTH + 1];		//网通IP
                                DWORD port;		//端口
                                DWORD dxport;		//电信端口
                                DWORD wtport;		//网通端口

                        } list_[0];
                        DWORD getSize()
                        {
                                return sizeof( *this ) + size_ * sizeof( list_[0] );
                        }

                };

                //查询服务器列表
                struct st_getServersByType: stMonitorBase		//11
                {
                        st_getServersByType()
                                : stMonitorBase( CMDIN_RMMT, SCMDIN_RMMT_SERVERLIST_REQ )
                        {
                                servertype = 0;
                        }
                        WORD servertype;		//6，Roomserver

                };
                //返回
                struct st_getServersByTypeRes: stMonitorBase		//12
                {
                        st_getServersByTypeRes()
                                : stMonitorBase( CMDIN_RMMT, SCMDIN_RMMT_SERVERLIST_RES )
                        {
                                servertype = 0;
                                ret_code_ = 0;
                                size_ = 0;
                        }
                        WORD ret_code_;
                        WORD servertype;		//与客户端发上来的type相同
                        WORD size_;		//下面list元素的个数
                        struct stRUL
                        {
                                DWORD serverid;		//服务器ID
                                char interIP[MAX_IP_LENGTH + 1];		//内网IP
                                DWORD load;		//服务器人数负载
                                WORD port;
                                char machineIP[MAX_IP_LENGTH + 1];

                        } list_[0];
                        DWORD getSize()
                        {
                                return sizeof( *this ) + size_ * sizeof( list_[0] );
                        }

                };
                //房间更改到指定房间服务器
                struct st_deployRoomToServer: stMonitorBase		//13
                {
                        st_deployRoomToServer()
                                : stMonitorBase( CMDIN_RMMT, SCMDIN_RMMT_ROOM_DEPLOY_REQ )
                        {
                                roomid = 0;
                                serverid_from = 0;
                                serverid_to = 0;
                        }

                        DWORD roomid;
                        DWORD serverid_from;		//房间当前服务器ID
                        DWORD serverid_to;		//房间要更改到的服务器ID

                };
                //返回
                struct st_deployRoomToServerRes: stMonitorBase		//14
                {
                        st_deployRoomToServerRes()
                                : stMonitorBase( CMDIN_RMMT, SCMDIN_RMMT_ROOM_DEPLOY_RES )
                        {
                                ret_code_ = 1;
                                roomid = 0;
                                serverid_from = 0;
                                serverid_to = 0;
                        }
                        WORD ret_code_;
                        DWORD roomid;
                        DWORD serverid_from;		//房间当前服务器ID
                        DWORD serverid_to;		//房间要更改到的服务器ID

                };

                //****************************************************************************************************************
                //查询服务器负载----曲线数据
                struct st_serverTotalloadReq: stMonitorBase		//1003,1
                {
                        st_serverTotalloadReq()
                                : stMonitorBase( CMDIN_RSVR, SCMDIN_RSVR_HISLOAD_REQ )
                        {
                                unit = 0;
                                type = 0;
                                queryby = 0;
                                queryid = 0;
                                value = 0;
                        }

                        BYTE fromtime[MAX_DATETIME_SIZE + 1];		//取数据起始时间
                        BYTE totime[MAX_DATETIME_SIZE + 1]; //结束时间
                        BYTE unit; //按照此时间取一次数据//0分钟    1小时    2天  3周    4月
                        BYTE type; //0最大值   1平均值
                        DWORD queryby; //0,查询某一服务器数据   1，查询某类服务器数据
                        DWORD queryid; //服务器ID 或者 类型ID （//6 房间服务器，  13 媒体服务器  2 Gateway服务器  3 Session服务器）
                        WORD value; //如果unit=0，values表示分钟数

                };
                //返回
                struct st_serverTotalloadRes: stMonitorBase //1003,2
                {
                        st_serverTotalloadRes()
                                : stMonitorBase( CMDIN_RSVR, SCMDIN_RSVR_HISLOAD_RES )
                        {
                                queryby = 0;
                                queryid = 0;
                                ret_code_ = 0;
                                size_ = 0;
                        }

                        DWORD queryby; //0,查询某一服务器数据   1，查询某类服务器数据
                        DWORD queryid; //服务器ID 或者 类型ID （//6 房间服务器，  13 媒体服务器  2 Gateway服务器  3 Session服务器）
                        WORD ret_code_;
                        WORD size_; //下面list元素的个数
                        struct stRUL
                        {
                                DWORD load; //在线人数
                                BYTE updatetime[MAX_DATETIME_SIZE + 1]; //数据对应的时间

                        } list_[0];
                        DWORD getSize()
                        {
                                return sizeof( *this ) + size_ * sizeof( list_[0] );
                        }

                };
                //服务器实时负载----表格数据
                struct st_serverRealdataReq: stMonitorBase //1003,3
                {
                        st_serverRealdataReq()
                                : stMonitorBase( CMDIN_RSVR, SCMDIN_RSVR_REALLOAD_REQ )
                        {
                                queryby = 0;
                                queryid = 0;
                        }

                        DWORD queryby; //0,查询某一服务器数据   1，查询某类服务器数据
                        DWORD queryid; //服务器ID 或者 类型ID （//6 房间服务器，  13 媒体服务器  2 Gateway服务器  3 Session服务器）

                };
                //返回
                struct st_serverRealdataRes: stMonitorBase //1003,4
                {
                        st_serverRealdataRes()
                                : stMonitorBase( CMDIN_RSVR, SCMDIN_RSVR_REALLOAD_RES )
                        {
                                queryby = 0;
                                queryid = 0;
                                ret_code_ = 0;
                                load = 0;
                        }

                        DWORD queryby; //0,查询某一房间数据   1，查询某类房间数据
                        DWORD queryid; //服务器ID 或者 类型ID
                        WORD ret_code_;

                        DWORD load; //人数
                        char serverip[MAX_IP_LENGTH + 1]; //服务器内网IP
                        char roomname[MAX_ROOM_NAME_SIZE + 1]; //机房名称

                };
                //GateWay服务器实时负载----表格数据
                struct st_gateWayRealdataReq: stMonitorBase //1003,5
                {
                        st_gateWayRealdataReq()
                                : stMonitorBase( CMDIN_RSVR, SCMDIN_RSVR_GATEWAY_REAL_REQ )
                        {
                                serverid = 0;
                        }

                        DWORD serverid; //serverid

                };
                //返回
                struct st_gateWayRealdataRes: stMonitorBase //1003,6
                {
                        st_gateWayRealdataRes()
                                : stMonitorBase( CMDIN_RSVR, SCMDIN_RSVR_GATEWAY_REAL_RES )
                        {
                                messageLost = 0;
                                connectFail = 0;
                                load = 0;
                                ret_code_ = 0;
                        }

                        WORD ret_code_;
                        DWORD load; //在线人数
                        DWORD messageLost; //丢消息数
                        DWORD connectFail; //连接失败数
                };

                //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                //查询实时负载
                struct st_RealtimeTotalReq: stMonitorBase
                {
                        st_RealtimeTotalReq()
                                : stMonitorBase( CMDIN_REAL, SCMDIN_REAL_TOTAL_REQ )
                        {

                        }

                };
                //返回实时负载
                struct st_RealtimeTotalRes: stMonitorBase
                {
                        st_RealtimeTotalRes()
                                : stMonitorBase( CMDIN_REAL, SCMDIN_REAL_TOTAL_RES )
                        {
                                ret_code_ = 1;
                                totallogin = 0;
                                maxonline = 0;
                                maxinroom = 0;
                        }

                        WORD ret_code_;
                        DWORD totallogin;
                        DWORD maxonline;
                        DWORD maxinroom;

                }
                ;

                //查询峰值负载
                struct st_PeakloadReq: stMonitorBase
                {
                        st_PeakloadReq()
                                : stMonitorBase( CMDIN_REAL, SCMDIN_REAL_PEAK_REQ )
                        {

                        }
                };
                //返回峰值负载
                struct st_PeakloadRes: stMonitorBase
                {

                        st_PeakloadRes()
                                : stMonitorBase( CMDIN_REAL, SCMDIN_REAL_PEAK_RES )
                        {
                                ret_code_ = 1;
                                login_d = 0;
                                online_d = 0;
                                inroom_d = 0;
                                login_w = 0;
                                online_w = 0;
                                inroom_w = 0;
                                login_m = 0;
                                online_m = 0;
                                inroom_m = 0;
                        }
                        WORD ret_code_;
                        DWORD login_d;
                        DWORD online_d;
                        DWORD inroom_d;
                        DWORD login_w;
                        DWORD online_w;
                        DWORD inroom_w;
                        DWORD login_m;
                        DWORD online_m;
                        DWORD inroom_m;

                };

                //查询服务器负载历史记录

                struct st_HistoryTotalReq: stMonitorBase
                {
                        st_HistoryTotalReq()
                                : stMonitorBase( CMDIN_REAL, SCMDIN_REAL_HISTORY_REQ )
                        {
                                unit = 0;
                                type = 0;
                                value = 1;
                        }
                        BYTE fromtime[MAX_DATETIME_SIZE + 1];
                        BYTE totime[MAX_DATETIME_SIZE + 1];
                        BYTE unit;	//0分钟    1小时    2天    3week 4month
                        BYTE type;	//0最大值   1平均值
                        WORD value;
                };
                //返回负载历史记录
                struct st_HistoryTotalRes: stMonitorBase
                {
                        st_HistoryTotalRes()
                                : stMonitorBase( CMDIN_REAL, SCMDIN_REAL_HISTORY_RES )
                        {
                                ret_code_ = 1;
                                size_ = 0;
                        }
                        WORD ret_code_;
                        WORD size_;
                        struct stRUL
                        {
                                DWORD totalload;
                                DWORD rotalrooms;
                                DWORD totalroomload;
                                BYTE updatetime[MAX_DATETIME_SIZE + 1];

                        } list_[0];
                        DWORD getSize()
                        {
                                return sizeof( *this ) + size_ * sizeof( list_[0] );
                        }

                };

                ////查询房间实时负载
                struct st_RealtimeRoomloadReq: stMonitorBase
                {

                        st_RealtimeRoomloadReq()
                                : stMonitorBase( CMDIN_REAL, SCMDIN_REAL_ROOMLOAD_REQ )
                        {

                                type = 0;
                        }
                        BYTE type;	//type=0 全部房间 type=1公共大厅
                };
                struct st_RealtimeRoomloadRes: stMonitorBase
                {
                        st_RealtimeRoomloadRes()
                                : stMonitorBase( CMDIN_REAL, SCMDIN_REAL_ROOMLOAD_RES )
                        {
                                ret_code_ = 1;
                                type_ = 0;
                                size_ = 0;
                        }
                        WORD ret_code_;
                        BYTE type_;
                        WORD size_;
                        struct stRUL
                        {

                                DWORD roomid;
                                DWORD total;
                                DWORD realtotal;
                                DWORD dummys;
                                DWORD medias;
                                WORD roomtype;
                                char roomname[MAX_ROOM_NAME_SIZE + 1];
                                DWORD serverid;
                        } list_[0];
                        DWORD getSize()
                        {
                                return sizeof( *this ) + size_ * sizeof( list_[0] );
                        }

                };

                ////查询房间实时负载
                struct st_QueryRoomListReq: stMonitorBase
                {
                        st_QueryRoomListReq()
                                : stMonitorBase( CMDIN_RMREAL, SCMDIN_ROOM_ROOMLIST_REQ )
                        {

                        }
                };
                struct st_QueryRoomListRes: stMonitorBase
                {
                        st_QueryRoomListRes()
                                : stMonitorBase( CMDIN_RMREAL, SCMDIN_ROOM_ROOMLIST_RES )
                        {
                                flag = 0;
                                size_ = 0;
                        }
                        uint8_t flag;  //是否清空之前的数据 0-start 1-during 2-finish
                        WORD size_;
                        struct stRUL {
                                DWORD roomid;
                                WORD roomtype;
                                char roomname[MAX_ROOM_NAME_SIZE + 1];
                        } list_[0];
                        DWORD getSize()
                        {
                                return sizeof( *this ) + size_ * sizeof( list_[0] );
                        }

                };

                struct st_RoomHistoryReq: stMonitorBase
                {
                        st_RoomHistoryReq()
                                : stMonitorBase( CMDIN_RMREAL, SCMDIN_ROOM_HISDATA_BYTYPE_REQ )
                        {
                                unit = 0;
                                type = 0;
                                queryby = 0;
                                queryid = 0;
                                value = 1;
                        }
                        BYTE fromtime[MAX_DATETIME_SIZE + 1];
                        BYTE totime[MAX_DATETIME_SIZE + 1];
                        BYTE unit;	//0分钟    1小时    2天    3week 4month
                        BYTE type;	//0最大值   1平均值
                        DWORD queryby;
                        DWORD queryid;
                        WORD value;
                };

                struct st_RoomHistoryRes: stMonitorBase
                {
                        st_RoomHistoryRes()
                                : stMonitorBase( CMDIN_RMREAL, SCMDIN_ROOM_HISDATA_BYTYPE_RES )
                        {
                                ret_code_ = 1;
                                size_ = 0;
                                queryby = 0;
                                queryid = 0;
                        }
                        DWORD queryby;
                        DWORD queryid;
                        WORD ret_code_;
                        WORD size_;
                        struct stRUL
                        {
                                DWORD roomload;
                                DWORD medias;
                                BYTE updatetime[MAX_DATETIME_SIZE + 1];

                        } list_[0];
                        DWORD getSize()
                        {
                                return sizeof( *this ) + size_ * sizeof( list_[0] );
                        }

                };

                struct st_RoomCurDataReq: stMonitorBase
                {
                        st_RoomCurDataReq()
                                : stMonitorBase( CMDIN_RMREAL, SCMDIN_ROOM_CURDATA_BYTYPE_REQ )
                        {
                                queryby = 0;
                                queryid = 0;
                        }
                        DWORD queryby;
                        DWORD queryid;
                };

                struct st_RoomCurDataRes: stMonitorBase
                {
                        st_RoomCurDataRes()
                                : stMonitorBase( CMDIN_RMREAL, SCMDIN_ROOM_CURDATA_BYTYPE_RES )
                        {
                                ret_code_ = 1;
                                queryby = 0;
                                queryid = 0;
                                total = 0;
                                realtotal = 0;
                                dummys = 0;
                                medias = 0;
                        }
                        DWORD queryby;
                        DWORD queryid;
                        WORD ret_code_;
                        DWORD total;	//显示人数
                        DWORD realtotal;	//真实人数
                        DWORD dummys;	//马甲人数
                        DWORD medias;	//语音数

                };

                struct st_killDuplicated: stMonitorBase
                {
                        st_killDuplicated()
                                : stMonitorBase( CMDIN_CTRL, SCMDIN_CTRL_KILL )
                        {
                                ret_code_ = 0;
                        }
                        char account[MAX_ACCOUNT_SIZE + 1];		//取数据起始时间
                        WORD ret_code_;

                };
               
                struct stGMUserIdByAccountReq : stMonitorBase
                {
                        stGMUserIdByAccountReq()
                                : stMonitorBase(CMDIN_GM, SCMDIN_GM_USER_ID_BY_ACCOUNT_REQ)
                        {
                                bzero(account_, sizeof(account_));
                        }

                        char account_[MAX_ACCOUNT_SIZE+1];              // 帐号
                };

                struct stGMUserIdByAccountRes : stMonitorBase
                {
                        stGMUserIdByAccountRes()
                                : stMonitorBase(CMDIN_GM, SCMDIN_GM_USER_ID_BY_ACCOUNT_RES)
                        {
                                bzero(account_, sizeof(account_));
                                user_id_ = 0;
                        }

                        char account_[MAX_ACCOUNT_SIZE+1];              // 帐号
                        DWORD user_id_;                                 // ID
                };

                struct stGMUserAccountByIdReq : stMonitorBase
                {
                        stGMUserAccountByIdReq()
                                : stMonitorBase(CMDIN_GM, SCMDIN_GM_USER_ACCOUNT_BY_ID_REQ)
                        {
                                user_id_ = 0;
                        }

                        DWORD user_id_;                                 // ID
                };

                struct stGMUserAccountByIdRes : stMonitorBase
                {
                        stGMUserAccountByIdRes()
                                : stMonitorBase(CMDIN_GM, SCMDIN_GM_USER_ACCOUNT_BY_ID_RES)
                        {
                                user_id_ = 0;
                        }

                        DWORD user_id_;                                 // ID
                        char account_[MAX_ACCOUNT_SIZE+1];              // 帐号
                };

                struct stGMUserOnlineInfoReq : stMonitorBase
                {
                        stGMUserOnlineInfoReq()
                                : stMonitorBase(CMDIN_GM, SCMDIN_GM_USER_ONLINE_INFO_REQ)
                        {
                                user_id_ = 0;
                        }

                        DWORD user_id_;                                 // ID
                };

                struct stGMUserOnlineInfoRes : stMonitorBase
                {
                        stGMUserOnlineInfoRes()
                                : stMonitorBase(CMDIN_GM, SCMDIN_GM_USER_ONLINE_INFO_RES)
                        {
                                user_id_ = 0;
                                size_ = 0;
                        }
                
                        DWORD getSize() const
                        {
                                return sizeof(*this) + size_*sizeof(json_[0]);
                        }

                        DWORD user_id_;                                 // ID
                        WORD size_;
                        char json_[0];
                        // json_ = ip(str) + gateway_server(uint) + session_server(uint) + room_id(uint)
                };

                struct stGMUserRoomInfoReq : stMonitorBase
                {
                        stGMUserRoomInfoReq()
                                : stMonitorBase(CMDIN_GM, SCMIND_GM_USER_ROOM_INFO_REQ)
                        {
                                room_id_ = 0;
                                user_id_ = 0;
                        }

                        DWORD room_id_;
                        DWORD user_id_;
                };

                struct stGMUserRoomInfoRes : stMonitorBase
                {
                        stGMUserRoomInfoRes()
                                : stMonitorBase(CMDIN_GM, SCMIND_GM_USER_ROOM_INFO_RES)
                        {
                                room_id_ = 0;
                                user_id_ = 0;
                                size_ = 0;
                        }

                        DWORD getSize() const
                        {
                                return sizeof(*this) + size_*sizeof(json_[0]);
                        }

                        DWORD room_id_;
                        DWORD user_id_;
                        WORD size_;
                        char json_[0];
                        // json_ = room_name(str) room_server(uint) + roommedia_server(uint)
                };

                struct stGMRoomMediaInfoReq : stMonitorBase
                {
                        stGMRoomMediaInfoReq()
                                : stMonitorBase(CMDIN_GM, SCMDIN_GM_ROOMMEDIA_INFO_REQ)
                        {
                                room_id_ = 0;
                        }

                        DWORD room_id_;
                };

                struct stGMRoomMediaInfoRes : stMonitorBase
                {
                        stGMRoomMediaInfoRes()
                                : stMonitorBase(CMDIN_GM, SCMDIN_GM_ROOMMEDIA_INFO_RES)
                        {
                                room_id_ = 0;
                                size_ = 0;
                        }

                        DWORD getSize() const
                        {
                                return sizeof(*this) + size_*sizeof(json_[0]);
                        }

                        DWORD room_id_;
                        WORD size_;
                        char json_[0];
                        // json_ = roommedia_server(value)...
                        // roommedia_server = id(uint) + ip(str) + net(uint) + load(uint) + max_load(uint)
                };

                struct stDispatchUserToMediaReq : stMonitorBase
                {
                        stDispatchUserToMediaReq()
                                : stMonitorBase(CMDIN_GM, SCMDIN_GM_DISPATCH_USER_TO_MEDIA_REQ)
                        {
                                room_id_ = 0;
                                user_id_ = 0;
                                from_media_id_ = 0;
                                to_media_id_ = 0;
                        }

                        DWORD room_id_;
                        DWORD user_id_;
                        WORD from_media_id_;
                        WORD to_media_id_;
                };

                struct stDispatchUserToMediaRes : stMonitorBase
                {
                        stDispatchUserToMediaRes()
                                : stMonitorBase(CMDIN_GM, SCMDIN_GM_DISPATCH_USER_TO_MEDIA_RES)
                        {
                                room_id_ = 0;
                                user_id_ = 0;
                                from_media_id_ = 0;
                                to_media_id_ = 0;
                                ret_code_ = 0;
                        }

                        DWORD room_id_;
                        DWORD user_id_;
                        WORD from_media_id_;
                        WORD to_media_id_;
                        BYTE ret_code_;
                };

                struct stSpecificServerListReq : stMonitorBase
                {
                        stSpecificServerListReq()
                                : stMonitorBase(CMDIN_GM, SCMDIN_GM_SPECIFIC_SERVER_LIST_REQ)
                        {
                        }
                };

                struct stSpecificServerListRes : stMonitorBase
                {
                        stSpecificServerListRes()
                                : stMonitorBase(CMDIN_GM, SCMDIN_GM_SPECIFIC_SERVER_LIST_RES)
                        {
                                size_ = 0;
                        }

                        DWORD getSize() const
                        {
                                return sizeof(*this) + size_*sizeof(json_[0]);
                        }

                        WORD size_;
                        char json_[0];
                        // json_ = room_server(value)...
                        // room_server = roomid(uint) + serverid(uint)
                };

                struct stAddSpecificServerReq : stMonitorBase
                {
                        stAddSpecificServerReq()
                                : stMonitorBase(CMDIN_GM, SCMDIN_GM_ADD_SPECIFIC_SERVER_REQ)
                        {
                                room_id_ = 0;
                                server_id_ = 0;
                        }

                        DWORD room_id_;
                        WORD server_id_;
                };

                struct stAddSpecificServerRes : stMonitorBase
                {
                        stAddSpecificServerRes()
                                : stMonitorBase(CMDIN_GM, SCMDIN_GM_ADD_SPECIFIC_SERVER_RES)
                        {
                                room_id_ = 0;
                                server_id_ = 0;
                                ret_code_ = 0;
                        }

                        DWORD room_id_;
                        WORD server_id_;
                        BYTE ret_code_;         // 0成功 非0失败
                };

                struct stDelSpecificServerReq : stMonitorBase
                {
                        stDelSpecificServerReq()
                                : stMonitorBase(CMDIN_GM, SCMDIN_GM_DEL_SPECIFIC_SERVER_REQ)
                        {
                                room_id_ = 0;
                        }

                        DWORD room_id_;
                };

                struct stDelSpecificServerRes : stMonitorBase
                {
                        stDelSpecificServerRes()
                                : stMonitorBase(CMDIN_GM, SCMDIN_GM_DEL_SPECIFIC_SERVER_RES)
                        {
                                room_id_ = 0;
                                ret_code_ = 0;
                        }

                        DWORD room_id_;
                        BYTE ret_code_;         // 0成功 非0失败
                };

                struct stDBServerListReq : stMonitorBase
                {
                        stDBServerListReq()
                                : stMonitorBase(CMDIN_GM, SCMDIN_GM_DB_SERVERLIST_REQ)
                        {
                                db_type_ = 0;
                        }

                        BYTE db_type_;          // 0:both 1:im 2:room
                };

                struct stDBServerListRes : stMonitorBase
                {
                        stDBServerListRes()
                                : stMonitorBase(CMDIN_GM, SCMDIN_GM_DB_SERVERLIST_RES)
                        {
                                db_type_ = 0;
                                size_ = 0;
                        }

                        DWORD getSize() const
                        {
                                return sizeof(*this) + size_*sizeof(json_[0]);
                        }

                        BYTE db_type_;          // 0:both 1:im 2:room
                        WORD size_;
                        char json_[0];
                        // json_ = server_info(value)...
                        // server_info = id(uint) + type(uint) + net(uint) + load(uint) + name(str) + ip_inner(str) + ip_listen(str) + ip_connect(str) + port(uint) + memo(str)
                };

                struct stMemServerListReq : stMonitorBase
                {
                        stMemServerListReq()
                                : stMonitorBase(CMDIN_GM, SCMDIN_GM_MEM_SERVERLIST_REQ)
                        {
                                super_type_ = 0;
                        }

                        BYTE super_type_;       // 0:both 1:super 2:roomsuper
                };

                struct stMemServerListRes : stMonitorBase
                {
                        stMemServerListRes()
                                : stMonitorBase(CMDIN_GM, SCMDIN_GM_MEM_SERVERLIST_RES)
                        {
                                super_type_ = 0;
                                size_ = 0;
                        }

                        DWORD getSize() const
                        {
                                return sizeof(*this) + size_*sizeof(json_[0]);
                        }

                        BYTE super_type_;       // 0:both 1:super 2:roomsuper
                        WORD size_;
                        char json_[0];
                        // json_ = server_info(value)...
                        // server_info = id(uint) + type(uint) + net(uint) + load(uint) + name(str) + ip_inner(str) + ip_listen(str) + ip_connect(str) + port(uint)
                };

                struct stReloadServerListNotify : stMonitorBase
                {
                        stReloadServerListNotify()
                                : stMonitorBase(CMDIN_GM, SCMDIN_GM_RELOAD_SERVERLIST_NOTIFY)
                        {
                                super_type_ = 0;
                        }

                        BYTE super_type_;       // 0:both 1:super 2:roomsuper
                };

                struct stAddServerReq : stMonitorBase
                {
                        stAddServerReq()
                                : stMonitorBase(CMDIN_GM, SCMDIN_GM_ADD_SERVER_REQ)
                        {
                                db_type_ = 0;
                                size_ = 0;
                        }

                        DWORD getSize() const
                        {
                                return sizeof(*this) + size_*sizeof(json_[0]);
                        }

                        BYTE db_type_;          // 1:im 2:room
                        WORD size_;
                        char json_[0];
                        // json_ = id(uint) + type(uint) + net(uint) + load(uint) + name(str) + ip_inner(str) + ip_listen(str) + ip_connect(str) + port(uint) + memo(str)
                };

                struct stAddServerRes : stMonitorBase
                {
                        stAddServerRes()
                                : stMonitorBase(CMDIN_GM, SCMDIN_GM_ADD_SERVER_REQ)
                        {
                                db_type_ = 0;
                                ret_code_ = 0;
                                size_ = 0;
                        }

                        DWORD getSize() const
                        {
                                return sizeof(*this) + size_*sizeof(json_[0]);
                        }

                        BYTE db_type_;          // 1:im 2:room
                        BYTE ret_code_;         // 0:成功 非0:失败
                        WORD size_;
                        char json_[0];
                        // json_ = id(uint) + type(uint) + net(uint) + load(uint) + name(str) + ip_inner(str) + ip_listen(str) + ip_connect(str) + port(uint) + memo(str)
                };

                struct stDelServerReq : stMonitorBase
                {
                        stDelServerReq()
                                : stMonitorBase(CMDIN_GM, SCMDIN_GM_DEL_SERVER_REQ)
                        {
                                db_type_ = 0;
                                server_id_ = 0;
                        }

                        BYTE db_type_;          // 1:im 2:room
                        WORD server_id_;
                };

                struct stDelServerRes : stMonitorBase
                {
                        stDelServerRes()
                                : stMonitorBase(CMDIN_GM, SCMDIN_GM_DEL_SERVER_RES)
                        {
                                db_type_ = 0;
                                server_id_ = 0;
                                ret_code_ = 0;
                        }

                        BYTE db_type_;          // 1:im 2:room
                        WORD server_id_;
                        BYTE ret_code_;         // 0:成功 非0:失败
                };
        };
};
//namespace MonitorFlash

//namespace Cmd
#pragma pack() //pack(1)
#endif /* MONITORCOMMAND4FLASH_H_ */
